package com.struts.core.listener;

import java.util.Map;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import com.struts.core.util.LoadStrutsConfigUtil;

public class MyListener implements ServletContextListener {

	private ServletContext context;
	@Override
	public void contextInitialized(ServletContextEvent event) {
		System.out.println(getClass()+" listener init started");
		context= event.getServletContext();
		String path = context.getRealPath("")+context.getInitParameter("struts");
		Map<String, Object> strutsMap = LoadStrutsConfigUtil.LoadStrutsConfig(path);
		context.setAttribute("strutsMap", strutsMap);
		System.out.println(getClass()+" listener init finished");
	}
	
	@Override
	public void contextDestroyed(ServletContextEvent e) {
		System.out.println(getClass()+" listener destroy finished");
	}
	

}
